use myprt.nu *

# 定义测试模块 te1_1
export module te1_1 {
    # 表格追加测试
    export def tt1 [] {
        prtH "te1_1 tt1"
        let first = [[a b]; [1 2]]
        let second = [[a b]; [3 4]]
        let result = ($first | append $second)
        # 断言测试
        # assert ($result | length) == 2
        # print "测试 te1_1.tt1 通过！"
        print $result
    }

    export def tt2 [] {
        prtH "te1_1 tt2"
        # 第二个表格没有列名
        let first = [[a b]; [1 2]]
        let second = [[3 4]]
        let result = ($first | append $second)
        # 断言测试
        # assert ($result | length) == 2
        # print "测试 te1_1.tt2 通过！"
        
        print $result
        print $result.0
        print $result.1
    }

    # 运行模块中的所有测试
    export def tt [] {
        tt1
        tt2
    }
}

# 定义测试模块 te1_2
export module te1_2 {
    export def tt1 [] {
        # print "运行测试 te1_2 tt1..."
        let data = [1 2 3 4 5]
        let result = ($data | math sum)

        # 断言测试
        assert $result == 15
        print "测试 te1_2.tt1 通过！"
    }

    export def tt2 [] {
        # print "运行测试 te1_2 tt2..."
        let data = ["hello" "world"]
        let result = ($data | str join " ")

        # 断言测试
        assert $result == "hello world"
        print "测试 te1_2.tt2 通过！"
    }

    # 运行模块中的所有测试
    export def run_all [] {
        tt1
        tt2
    }
}

# 运行所有测试模块
export def run_all [] {
    te1_1.run_all
    te1_2.run_all
}